typedef struct {
    int* data;
    int front, rear;
    int size;
} MyCircularQueue;

MyCircularQueue* myCircularQueueCreate(int k) {
    MyCircularQueue* mcq = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    if (mcq == NULL)
    {
        perror("malloc error");
    }
    int* data1 = (int*)malloc(sizeof(int) * (k + 1));
    if (data1 == NULL)
    {
        perror("malloc error");
    }
    mcq->data = data1;
    mcq->front = mcq->rear = 0;
    mcq->size = k + 1;
    return mcq;
}

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if ((obj->rear + 1 + obj->size) % obj->size != obj->front)
    {
        obj->data[obj->rear] = value;
        obj->rear = (obj->rear + 1 + obj->size) % obj->size;
        return true;
    }
    return false;
}

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
        return false;
    obj->front = (obj->front + 1 + obj->size) % obj->size;
    return true;
}

int myCircularQueueFront(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
        return -1;
    return obj->data[obj->front];
}

int myCircularQueueRear(MyCircularQueue* obj) {
    if (obj->front == obj->rear)
        return -1;
    return obj->data[(obj->rear - 1 + obj->size) % obj->size];
}

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    return obj->front == obj->rear;
}

bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return (obj->rear + 1 + obj->size) % obj->size == obj->front;
}

void myCircularQueueFree(MyCircularQueue* obj) {
    free(obj->data);
    obj->data = NULL;
    free(obj);
    obj = NULL;
}